<!DESCRIPTION>Want to display content that only gets shown once every x hours? With this unique script you can do just that! By using JavaScript cookies and CSS ("display" property), this script lets you cap the display frequency of any content(s) on the page to once every x hours. Each content can have its own frequency cap, and setting up the script is as easy as specifying the IDs of the contents inside the script.
Frequency capping is a great way to maximize the impact of a content, to avoid visual "burnout." Use it on content ads, special announcements etc.
<!/DESCRIPTION>
<!CATEGORY>dynamic content<!/CATEGORY>
<!SCRIPT>
<!-- START OF SCRIPT -->
<!-- Step 1: Insert the below script into the HEAD section of your page: -->
<script type="text/javascript">
/***********************************************
* Frequency Cap Content script- ⌐ Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
//["ID of content to frequency cap", "Display frequency interval (full hours only)"]
if (get_cookie(capcontent[i][0])!=parseInt(capcontent[i][1]))
resetcookie(capcontent[i][0])
showorhide(capcontent[i])
}
document.write('</style>')
</script>
<!-- An array inside the script lets you input the IDs of the contents to frequency cap, plus the display interval in hours.
Step 2: With the script installed, simply give the contents you want to frequency cap each with the ID as specified in the script above. For example:
<div id="myad">
//some content
//some content
</div><table id="mynote">
//rest of table here
</table>As you can see, the content can be anything, whether it's a DIV, table, or even an image etc. In the above case, the DIV will be shown once every hour, and the TABLE, once every 3 hours.
Useful tip: To reset the cookie for a specific content so it gets shown again, simply change the time interval for it inside array capcontent[] so it's different from the current interval (for example, from the current 1 hour to 2 hour). The script will reset the cookie whenever it detects a change in time interval from the previous for a content. This is useful for debugging/ testing purposes.
Cool!
-->
<!-- END OF SCRIPT -->
<!/SCRIPT>
<!PREVIEW>
<!-- START OF SCRIPT -->
<!-- Step 1: Insert the below script into the HEAD section of your page: -->
<script type="text/javascript">
/***********************************************
* Frequency Cap Content script- ⌐ Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
//["ID of content to frequency cap", "Display frequency interval (full hours only)"]
if (get_cookie(capcontent[i][0])!=parseInt(capcontent[i][1]))
resetcookie(capcontent[i][0])
showorhide(capcontent[i])
}
document.write('</style>')
</script>
<!-- An array inside the script lets you input the IDs of the contents to frequency cap, plus the display interval in hours.
Step 2: With the script installed, simply give the contents you want to frequency cap each with the ID as specified in the script above. For example:
<div id="myad">
//some content
//some content
</div><table id="mynote">
//rest of table here
</table>As you can see, the content can be anything, whether it's a DIV, table, or even an image etc. In the above case, the DIV will be shown once every hour, and the TABLE, once every 3 hours.
Useful tip: To reset the cookie for a specific content so it gets shown again, simply change the time interval for it inside array capcontent[] so it's different from the current interval (for example, from the current 1 hour to 2 hour). The script will reset the cookie whenever it detects a change in time interval from the previous for a content. This is useful for debugging/ testing purposes.